package dao;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.stereotype.Repository;
import pojo.Schedule;

import java.util.List;

@Repository
public class ScheduleDAO extends BaseDAO<Schedule>{

    public ScheduleDAO() {
        super(Schedule.class);
    }

    public List<Schedule> queryByRoom(Schedule schedule) {
        return getHibernateTemplate().execute(new HibernateCallback<List<Schedule>>() {
            @Override
            public List<Schedule> doInHibernate(Session session) throws HibernateException {
                List<Schedule> list = session.createQuery("from Schedule where user_id=:xx").setParameter("xx", schedule.getSysUsers().getId()).list();
                return list;
            }
        });
    }
}
